#include "devicemgt.h"
#include "ui_devicemgt.h"

DeviceMgt::DeviceMgt(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DeviceMgt) {
    ui->setupUi(this);

    ui->tableWidget->setColumnCount(7);
    QStringList header;
    header << "设备ID" << "设备名称" << "设备类型" << "设备安装位置" << "制造商" << "型号" << "安装日期";
    ui->tableWidget->setHorizontalHeaderLabels(header);
    ui->tableWidget->setColumnWidth(0, 100);
    ui->tableWidget->setColumnWidth(1, 100);
    ui->tableWidget->setColumnWidth(2, 100);
    ui->tableWidget->setColumnWidth(3, 250);
    ui->tableWidget->setColumnWidth(4, 150);
    ui->tableWidget->setColumnWidth(5, 100);
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(6, QHeaderView::Stretch);

    ui->tableWidget->verticalHeader()->setVisible(false);

    insertTableItems();
}

DeviceMgt::~DeviceMgt()
{
    delete ui;
}

void DeviceMgt::insertTableItems() {
    for(int i = 0; i < 10; i++) {
            int row = ui->tableWidget->rowCount();
            ui->tableWidget->insertRow(row);
            // 初始化每个单元格
            for (int col = 0; col < 7; col++) {
                QTableWidgetItem *item = new QTableWidgetItem(""); // 占位数据
                ui->tableWidget->setItem(row, col, item);
            }
        }
}
